$(function () {
    $('#generalApproval_datagrid').datagrid({
        url:'/tempSave/list',
        fitColumns:true,
        height:'350',
        pagination:true,
        rownumbers:true,
        singleSelect:true,
        columns:[[
            {field:'ob.orderBillNumber',title:'保单号',width:100,align:'center',
                formatter: function(value,row,index){
                    console.log(row)
                    if(row.insurancePolicyNumber){
                        return row.insurancePolicyNumber
                    }else{
                        return ""
                    }
                }
            },
            {field:'ob.orderBillNumber',title:'申请批改单号',width:100,align:'center',
                formatter: function(value,row,index){
                    console.log(row)
                    if(row.insurancePolicyNumber){
                        return row.insurancePolicyNumber
                    }else{
                        return ""
                    }
                }
            },
            {field:'c_name',title:'投保人名称',width:100,align:'center',
                formatter: function(value,row,index){
                    console.log(row)
                    if(row.beApply){
                        return row.beApply.realName
                    }else{
                        return ""
                    }
                }
            },
            {field:'carNumber',title:'车牌号',width:100,align:'center'},
            {field:'product.name',title:'产品名称',width:100,align:'center',
                formatter: function(value,row,index){
                    console.log(row)
                    if(row.product){
                        return row.product.name
                    }else{
                        return ""
                    }
                }
            },
            {field:'insuranceInfoChange.applicationTime',title:'批改申请时间',width:100,align:'center',
                formatter: function(value,row,index){
                    console.log(row)
                    if(row.product){
                        return row.product.name
                    }else{
                        return ""
                    }
                }
            },
        ]]
    })
})
function serach() {
    var ogName = $('#ogName').val();
    var parent_product_name = $('#parent_product_name').val();
    var apply_name = $('#apply_name').val()
    var apply_time_min = $('#apply_time_min').datebox('getValue')
    var apply_time_max = $('#apply_time_max').datebox('getValue')
    if(apply_time_max==""){
        apply_time_max = '01/01/2017'
    }
    if(apply_time_min==""){
        apply_time_min = '01/01/2099'
    }
    var insurancePolicyNumber = $('#insurancePolicyNumber').val()
    var carNumber = $('#carNumber').val()
    var be_apply_number = $('#be_apply_number').val()
    $('#generalApproval_datagrid').datagrid('load',{
        organizationName:ogName,
        produtName:parent_product_name,
        applyClientName:apply_name,
        minApplyTime:apply_time_min,
        maxApplyTime:apply_time_max,
        insurancePolicyNumber:insurancePolicyNumber,
        carNumber:carNumber,
        beApplyClientName:be_apply_number
    });
}

function reload(){
    $('#generalApproval_datagrid').datagrid('reload');
}
function remove() {
    var row = $('#generalApproval_datagrid').datagrid('getSelected');
    if(row){
        $.messager.confirm('确认对话框', '您想要删除该项吗？', function(r){
            if (r){
                if (row) {
                    var rowIndex = $('#generalApproval_datagrid').datagrid('getRowIndex', row);
                    $('#generalApproval_datagrid').datagrid('deleteRow', rowIndex);
                }
            }
        });
    }else{
       $.messager.alert('温馨提示','请选择需要删除的项','warning');
    }
}
/*function fast_appravl_deal() {
    var selectedVal = $('#generalApproval_datagrid').datagrid('getSelected');
    var idval = selectedVal.insurancePolicyNumber
    if(selectedVal){
        window.location.href ='/insuranceInfoChange?insurancePolicyNumber='+idval;
    }else{
        $.messager.alert('温馨提示','请选择需要审批/退保的条目','warning')
    }
}*/
function fast_appravl_deal() {
    var selectedVal = $('#generalApproval_datagrid').datagrid('getSelected');
    if(selectedVal){
        var idval = selectedVal.insurancePolicyNumber
        window.location.href ='/insuranceInfoChange?insurancePolicyNumber='+idval;
    }else{
        $.messager.alert('温馨提示','请选择需要审批/退保的条目','warning')
    }
}

